﻿#region [ License information          ]
/* ************************************************************
 *
 * Copyright (c) Bjørn Bouet Smith, 2010, 2011
 *
 * This source code is subject to terms and conditions of 
 * Microsoft Public License (Ms-PL).
 * 
 * A copy of the license can be found in the license.txt
 * file at the root of this distribution. If you can not 
 * locate the License, please send an email to bjornsmith@gmail.com
 * 
 * By using this source code in any fashion, you are 
 * agreeing to be bound by the terms of the Microsoft 
 * Permissive License.
 *
 * You must not remove this notice, or any other, from this
 * software.
 *
 * ************************************************************/
#endregion

using System;

namespace Smith.AMC.Operations
{
    /// <summary>
    /// class that is used to hold information about the response the memcached server sends back to the client.
    /// </summary>
    public class OperationResponse
    {
        /// <summary>
        /// Gets or sets the server response, i.e. the raw bytes the server sends
        /// </summary>
        public byte[] ServerResponse
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the flags part of the server response.
        /// Will only be available after the <see cref="ServerResponse"/> has been pre parsed
        /// </summary>
        public ushort Flags
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the cache key.
        /// Will only be available after the <see cref="ServerResponse"/> has been pre parsed
        /// </summary>
        public string CacheKey
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the CAS value to be used for CAS operations
        /// Will only be available after the <see cref="ServerResponse"/> has been pre parsed
        /// </summary>
        public ulong CASValue
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the length of the actual data, i.e. not the entire server response, but the data part.
        /// Will only be available after the <see cref="ServerResponse"/> has been pre parsed
        /// </summary>
        public int DataLength
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets position within the <see cref="ServerResponse"/> the actual data starts.
        /// Will only be available after the <see cref="ServerResponse"/> has been pre parsed
        /// </summary>
        public int DataStart
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the name of the operation that this response is a response to.
        /// </summary>
        public string OperationName
        {
            get;
            set;
        }
    }

    /// <summary>
    /// Represents a stronly typed OperationResponse
    /// </summary>
    /// <typeparam name="T">The type this operation wraps</typeparam>
    public class OperationResponse<T> : OperationResponse
    {
    }
}
